package com.example.budget3.data;

import java.util.Date;



public class RecurrTransactionData {
	private String name;
	private float cost;
	private Date nextTimeDate; 
	private int period;
	private int minute;
	private int hour;
	private int dayOfWeek;
	private int dayOfMonth;
	private boolean type;
	private int id;
	private ExpenseCategory expenseCategory;
	private IncomeCategory incomeCategory;

	public RecurrTransactionData(int id, String name, float cost, IncomeCategory category,
			Date timeDate, boolean type, int period, int arg1, int arg2) {
		this.id = id;
		this.name = name;
		this.cost = cost;
		this.incomeCategory = category;
		this.nextTimeDate = timeDate;
		this.type = type;
		this.period = period;
		if(period == 0){
			minute = arg1;
			hour = arg2;
		}else if(period ==1){
			dayOfWeek = arg1;
		}else{
			dayOfMonth = arg1;
		}
	}

	public RecurrTransactionData(int id, String name, float cost, ExpenseCategory category,
			Date timeDate, boolean type, int period, int arg1, int arg2) {
		this.id = id;
		this.name = name;
		this.cost = cost;
		this.expenseCategory = category;
		this.nextTimeDate = timeDate;
		this.type = type;
		this.period = period;
		if(period == 0){
			minute = arg1;
			hour = arg2;
		}else if(period ==1){
			dayOfWeek = arg1;
		}else{
			dayOfMonth = arg1;
		}
	}

	public String getName() {
		return name;
	}

	public float getCost() {
		return cost;
	}

	public Date getNextTimeDate() {
		return nextTimeDate;
	}

	public int getPeriod() {
		return period;
	}

	public int getMinute() {
		return minute;
	}

	public int getHour() {
		return hour;
	}

	public int getDayOfWeek() {
		return dayOfWeek;
	}

	public int getDayOfMonth() {
		return dayOfMonth;
	}

	public boolean isType() {
		return type;
	}

	public int getId() {
		return id;
	}

	public ExpenseCategory getExpenseCategory() {
		return expenseCategory;
	}

	public IncomeCategory getIncomeCategory() {
		return incomeCategory;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Float.floatToIntBits(cost);
		result = prime * result + dayOfMonth;
		result = prime * result + dayOfWeek;
		result = prime * result
				+ ((expenseCategory == null) ? 0 : expenseCategory.hashCode());
		result = prime * result + hour;
		result = prime * result + id;
		result = prime * result
				+ ((incomeCategory == null) ? 0 : incomeCategory.hashCode());
		result = prime * result + minute;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((nextTimeDate == null) ? 0 : nextTimeDate.hashCode());
		result = prime * result + period;
		result = prime * result + (type ? 1231 : 1237);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		RecurrTransactionData other = (RecurrTransactionData) obj;
		if (Float.floatToIntBits(cost) != Float.floatToIntBits(other.cost))
			return false;
		if (dayOfMonth != other.dayOfMonth)
			return false;
		if (dayOfWeek != other.dayOfWeek)
			return false;
		if (expenseCategory != other.expenseCategory)
			return false;
		if (hour != other.hour)
			return false;
		if (id != other.id)
			return false;
		if (incomeCategory != other.incomeCategory)
			return false;
		if (minute != other.minute)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (nextTimeDate == null) {
			if (other.nextTimeDate != null)
				return false;
		} else if (!nextTimeDate.equals(other.nextTimeDate))
			return false;
		if (period != other.period)
			return false;
		if (type != other.type)
			return false;
		return true;
	}


}
